<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <title>Document</title>
    <style>
        .box {
          width: 300px;
          height: 300px;
          /* background-color: red; */
          border: 1px solid #000;
        }
      </style>
</head>
<body>
    <div class="box"></div>
    <script>
        const box = document.querySelector(".box")
        function center (e){
            console.log(e.target)
            console.log(this)
            console.log("center")
        }
        function leave(){
            this.style.background = ""
        }
        function enter(){
            this.style.background = "red"
        } 
        box.onmouseenter = _.throttle(enter,2000,{
        //lodash的节流提供两个配置,leading控制节流返回的回调函数是否在初始的时候触发,trailing控制节流返回的回调函数是否在最后也触发(是否在时间到了再触发一次)
            leading: true,
            trailing: false,
        })
        box.onmouseleave = leave

    </script>
</body>
</html>